| Conditions | 3 |
| Total Lines | 31 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import isEqualWith from "lodash/isEqualWith"; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Logs to console any values which are not equal. |
||
| 10 | * DO NOT USE IN PRODUCTION. |
||
| 11 | */ |
||
| 12 | function deepEqualsDebug(object: any, other: any): boolean { |
||
| 13 | const debugCompare = (a, b, key) => { |
||
| 14 | const equality = isEqual(a, b); |
||
| 15 | if (!equality) { |
||
| 16 | console.debug(`The values at key/index ${key} were not equal:`, a, b); |
||
| 17 | } |
||
| 18 | return equality; |
||
| 19 | }; |
||
| 20 | if ( |
||
| 21 | typeof object === "object" && |
||
| 22 | typeof other === "object" && |
||
| 23 | object !== null && |
||
| 24 | other !== null |
||
| 25 | ) { |
||
| 26 | return ( |
||
| 27 | debugCompare( |
||
| 28 | Object.keys(object).length, |
||
| 29 | Object.keys(other).length, |
||
| 30 | "length", |
||
| 31 | ) && |
||
| 32 | Object.keys(object).every((key) => |
||
| 33 | debugCompare(object[key], other[key], key), |
||
| 34 | ) |
||
| 35 | ); |
||
| 36 | } |
||
| 37 | return isEqualWith(object, other, debugCompare); |
||
| 38 | } |
||
| 41 |